package utils;

import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.HashSet;

public class setOperation {
    public static <T> HashSet<T> getUnionSet(HashSet<T> set1, HashSet<T> set2) {
        HashSet<T> res = new HashSet<>();
        res.addAll(set1);
        res.retainAll(set2);
        return res;
    }
    /**
     * 对比两个hashMap的文件差异，返回差集
     * @param map1
     * @param map2
     * @return HashSet<T>
     */
    public static <T> HashSet<T> getDifference(HashMap<T,T> map1, HashMap<T,T> map2) {
        HashSet<T> set1 = new HashSet<>(map1.keySet());
        HashSet<T> set2 = new HashSet<>(map2.keySet());
        HashSet<T> res = new HashSet<>();
        res.addAll(set1);
        res.retainAll(set2);
        set1.removeAll(res);
        return set1;
    }

}
